class Broker {
  private command: Command

  public setCommand (command: Command) {
    this.command = command
  }

  public execute () {
    this.command.execute()
  }
}

interface Command {
  execute (): void
}

class EditCommand implements Command {
  execute () {
    console.log("edit")
  }
}


class InsertCommand implements Command {
  execute () {
    console.log("insert")
  }
}


function main () {
  let edit = new EditCommand()
  let insert = new InsertCommand()
  let broker = new Broker()
  broker.setCommand(edit)
  broker.execute()

  broker.setCommand(insert)
  broker.execute()
}

main()